//
//  MYGMeAPI.swift
//  MYDoctor
//
//  Created by Denny on 2024/4/2.
//

import UIKit
import Foundation
import Moya
/**
 行业资讯接口
 */
enum MYGHomePageAPI:MYGTargetType {
    case getIndInfoList(param: [String: Any])//行业资讯
    case informationDetail(param: [String: Any])//行业资讯详情
    case getNewsList(param: [String: Any])//新闻列表
    case getFlowers(param: [String: Any])//红人榜
    case getActives(param: [String: Any])//活跃榜
    case getPatientList(param: [String: Any])//患者列表
    case addPatient(param: [String: Any])//新增患者
    case scheduleDay(param: [String: Any])//首页日程
    case doctorApplicationInfo(patientPhone: String, reportId: String) // reportId 申请查看的类型（1健康数据2生活习惯3健康史4病历夹5体检报告）这里只能查看一个
    //学术会议
    
    case meetList(param: [String: Any])
    case meetingDetailTime(param: [String: Any])
    case meetingDetail(param: [String: Any])
    case foreign(param: [String: Any])//日程一览
    case expert_detail(param: [String: Any])//专家详情
    case foreign_detail(param: [String: Any])//日程一览详情
    case meeting_sign(param: [String: Any])//会议签到
    
}
extension MYGHomePageAPI {
    var path: String {
        
        switch self {
        case .meetingDetail:
            return "/meeting/index/meeting_detail"
        case .meetingDetailTime:
            return "/meeting/index/meeting_detail_time"
        case .meetList:
            return "/meeting/index/meeting_list"
        case .scheduleDay:
            return "/api/schedule/schedule"
        case .informationDetail:
            return "/api/article/doctor_info_detail"
        case .getIndInfoList:
            return "/api/article/doctor_info"
        case .getNewsList:
            return "/news/list"
        case .getFlowers:
            return "/xinglin/flower"
        case .getActives:
            return "/xinglin/active"
        case .getPatientList:
            return "/api/doctor/patient"
        case .addPatient:
            return "/api/doctor/doctor_add_patient"
        case .doctorApplicationInfo:
            return "/api/doctor/DoctorApplicationInfo"
        case .foreign:
            return "/meeting/index/foreign"
        case .expert_detail:
            return "/meeting/index/expert_detail"
        case .foreign_detail:
            return "/meeting/index/foreign_detail"
        case .meeting_sign:
            return "/meeting/index/meeting_sign"
        }
    }
    var baseURL: URL {
        switch self {
        case .getIndInfoList,.informationDetail,.getPatientList,.addPatient,.scheduleDay,.doctorApplicationInfo,.meetList,.meetingDetailTime,.meetingDetail,.foreign,.expert_detail,.foreign_detail,.meeting_sign:
            return  URL(string: BaseUrl)!
        case
                .getNewsList,.getFlowers,.getActives:
            return  URL(string: Url)!
        }
    }
    
    var method: Moya.Method {
        switch self {
        case .getIndInfoList,
                .getNewsList,
                .getPatientList,
                .informationDetail,
                .meetList,
                .meetingDetail,
                .scheduleDay,
                .addPatient,
                .meetingDetailTime,
                .doctorApplicationInfo,
                .foreign,
                .expert_detail,
                .foreign_detail,
                .meeting_sign:
            return .get
        case .getFlowers,.getActives:
            return .post
        }
    }

    var params: [String : Any] {
        switch self {
        case .getIndInfoList(param: let param),
                .getNewsList(param: let param),
                .getFlowers(param: let param),
                .getActives(param: let param),
                .scheduleDay(param: let param),
                .informationDetail(param: let param),
                .getPatientList(param: let param),
                .meetingDetailTime(param: let param),
                .meetList(param: let param),
                .meetingDetail(param: let param),
                .addPatient(param: let param),
                .foreign(param: let param),
                .expert_detail(param: let param),
                .foreign_detail(param: let param),
                .meeting_sign(param: let param):
            return param
        case let .doctorApplicationInfo(patientPhone, reportId):
            var params: [String: Any] = [:]
            params["doctor_phone"] = "\(MYGUserManager.getUser()?.doctor.phone ?? 0)"
            params["patient_phone"] = patientPhone
            params["report_id"] = reportId
            return params
        }
    }
}

